package com.bestow.basic.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.bestow.common.annotation.Log;
import com.bestow.common.core.controller.BaseController;
import com.bestow.common.core.domain.AjaxResult;
import com.bestow.common.enums.BusinessType;
import com.bestow.basic.domain.HlsBpType;
import com.bestow.basic.service.IHlsBpTypeService;
import com.bestow.common.utils.poi.ExcelUtil;
import com.bestow.common.core.page.TableDataInfo;

/**
 * 商业伙伴类型Controller
 * 
 * @author liliu
 * @date 2022-09-02
 */
@RestController
@RequestMapping("/basic/bpType")
public class HlsBpTypeController extends BaseController
{
    @Autowired
    private IHlsBpTypeService hlsBpTypeService;

    /**
     * 查询商业伙伴类型列表
     */
    @PreAuthorize("@ss.hasPermi('basic:bpType:list')")
    @GetMapping("/list")
    public TableDataInfo list(HlsBpType hlsBpType)
    {
        startPage();
        List<HlsBpType> list = hlsBpTypeService.selectHlsBpTypeList(hlsBpType);
        return getDataTable(list);
    }

    /**
     * 导出商业伙伴类型列表
     */
    @PreAuthorize("@ss.hasPermi('basic:bpType:export')")
    @Log(title = "商业伙伴类型", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, HlsBpType hlsBpType)
    {
        List<HlsBpType> list = hlsBpTypeService.selectHlsBpTypeList(hlsBpType);
        ExcelUtil<HlsBpType> util = new ExcelUtil<HlsBpType>(HlsBpType.class);
        util.exportExcel(response, list, "商业伙伴类型数据");
    }

    /**
     * 获取商业伙伴类型详细信息
     */
    @PreAuthorize("@ss.hasPermi('basic:bpType:query')")
    @GetMapping(value = "/{bpType}")
    public AjaxResult getInfo(@PathVariable("bpType") String bpType)
    {
        return AjaxResult.success(hlsBpTypeService.selectHlsBpTypeByBpType(bpType));
    }

    /**
     * 新增商业伙伴类型
     */
    @PreAuthorize("@ss.hasPermi('basic:bpType:add')")
    @Log(title = "商业伙伴类型", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody HlsBpType hlsBpType)
    {
        return toAjax(hlsBpTypeService.insertHlsBpType(hlsBpType));
    }

    /**
     * 修改商业伙伴类型
     */
    @PreAuthorize("@ss.hasPermi('basic:bpType:edit')")
    @Log(title = "商业伙伴类型", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody HlsBpType hlsBpType)
    {
        return toAjax(hlsBpTypeService.updateHlsBpType(hlsBpType));
    }

    /**
     * 删除商业伙伴类型
     */
    @PreAuthorize("@ss.hasPermi('basic:bpType:remove')")
    @Log(title = "商业伙伴类型", businessType = BusinessType.DELETE)
	@DeleteMapping("/{bpTypes}")
    public AjaxResult remove(@PathVariable String[] bpTypes)
    {
        return toAjax(hlsBpTypeService.deleteHlsBpTypeByBpTypes(bpTypes));
    }
}
